import request from '@/utils/request'

export const getDishList = function(params) {
  return request({
    url: '/dish/page',
    method: 'get',
    params
  })
}

export const deleteDish = function(ids) {
  return request({
    url: '/dish',
    method: 'delete',
    params: { ids }
  })
}

export const editDish = function(params) {
  return request({
    url: '/dish',
    method: 'put',
    data: { ...params }
  })
}

export const addDish = function(params) {
  return request({
    url: '/dish',
    method: 'post',
    data: { ...params }
  })
}

export const dishStatusByStatus = (params) => {
  return request({
    url: `/dish/status/${params.status}`,
    method: 'post',
    params: { ids: params.id }
  })
}

export const getCategoryList = (params) => {
  return request({
    url: '/category/list',
    method: 'get',
    params
  })
}

export const queryDishById = (id) => {
  return request({
    url: `/dish/${id}`,
    method: 'get'
  })
}

export const downloadImg = (name) => {
  return `${process.env.VUE_APP_BASE_API}/common/download/?name=${name}`
}

export const getDishDetail = (params) => {
  return request({
    url: '/dish/list',
    method: 'get',
    params
  })
}
